#while循环
i=1
while i<=9:
    j=1
    while j<=i:
        print('{}*{}={:>4}'.format(i,j,i*j),end=' ')
        j=j+1
    i=i+1
    print(' ')
print("="*60)

i=9
while i>=1:
    j=1
    while j<=i:
        print('{}*{}={:>4}'.format(i, j, i * j), end=' ')
        j=j+1
    i=i-1
    print(' ')
print("="*60)


i = 1
while i < 10:
    j = i
    while j >= 1:
        a = "{}*{}={:<4}".format(j, i, i * j)

        if i == j:
            print(a.rjust(8 * (10 - i)), end="")
        else:
            print(a, end="")
        j -= 1

    i += 1
    print(" ")
print('='*60)

i = 9
while i >= 1:
    j = i
    while j >= 1:
        b = "{}*{}={:<4}".format(j, i, i * j)

        if i == j:
            print(b.rjust(8 * (10 - i)), end="")
        else:
            print(b, end="")
        j -= 1

    i -= 1
    print(" ")
print('='*60)
#for in循环
for i in range(1,10):
    for j in range(1,i+1):
        print('{}*{}={:>4}'.format(i,j,i*j),end=' ')
    print(' ')
print("="*60)

for i in range(9,0,-1):
    for j in range(1,i+1):
        print('{}*{}={:>4}'.format(i,j,i*j),end=' ')
    print(' ')
print("="*60)

for i in range(1, 10):
    for k in range(1, 10 - i):
        print(end="       ")
    for j in range(i, 0, -1):
        print('{}*{}={:>2}'.format(j, i, j * i), end=' ')
    print("")
print('=' * 60)


for i in range(9, 0, -1):
    for k in range(1, 10 - i):
        print(end="       ")
    for j in range(i, 0, -1):
        print('{}*{}={:>2}'.format(j, i, j * i), end=' ')
    print(' ')

print('=' * 60)
